/**
 * 〈所属模块〉
 * 〈功能描述〉
 *
 * @author Lcs
 * @date 2017/9/15 13:27
 */

import React, { Component } from "react";
import { StyleSheet, Text, Image } from "react-native";

import {
  Color, ScreenWidth, FontSize, scale,
} from "../common";
import NavigatorUtil from "../utils/NavigatorUtil";
import BasePage from "../widget/common/BasePage";
import Button from "../widget/common/NCButton";
import EnumConstants from "../common/EnumConstants";

const { OrderType } = EnumConstants;
let type;
let orderId;

export default class OrderSuccess extends Component {
  constructor(props) {
    super(props);
    orderId = NavigatorUtil.getPageParam(props, "orderId");
    type = NavigatorUtil.getPageParam(props, "type");
  }

  componentWillMount() {}

  goOrderInfo = () => {
    if (type === OrderType.RECYCLE) {
      NavigatorUtil.goRecycleOrderInfo(orderId);
    } else if (type === OrderType.UPDATE) {
      NavigatorUtil.goUpdateOrderInfo(orderId);
    } else {
      NavigatorUtil.goServiceOrderInfo(orderId);
    }
  };

  render() {
    return (
      <BasePage style={styles.container}>
        <Image source={require("../img/ic_order_success.png")} style={styles.image} resizeMode="stretch" />
        <Text style={styles.textMain}>下单成功</Text>
        <Text style={styles.textDesc}>请保持手机通话畅通，工作人员会与您确认上门回收细节</Text>
        <Button
          onPress={this.goOrderInfo}
          buttonStyle={styles.btnContainer}
          textStyle={styles.btnText}
          title="订单详情"
        />
        <Button
          onPress={() => NavigatorUtil.goHome()}
          buttonStyle={styles.btnContainer2}
          textStyle={styles.btnText}
          title="返回首页"
        />
      </BasePage>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: "center",
    paddingTop: scale * 50,
    backgroundColor: Color.white,
  },
  image: {
    width: scale * 210,
    height: scale * 138,
  },
  textMain: {
    fontSize: FontSize.SIZE_28,
    color: Color.text_title,
    marginTop: scale * 18,
  },
  textDesc: {
    fontSize: FontSize.SIZE_14,
    color: Color.text_desc,
    marginTop: scale * 18,
    paddingHorizontal: scale * 54,
  },
  btnText: {
    fontSize: FontSize.SIZE_17,
    color: Color.text_title,
  },
  btnContainer: {
    height: 44 * scale,
    width: ScreenWidth - 32 * scale,
    marginTop: 24 * scale,
    marginHorizontal: 16 * scale,
    borderRadius: 5 * scale,
    borderColor: Color.tab_yellow,
    alignItems: "center",
    justifyContent: "center",
    backgroundColor: Color.tab_yellow,
  },
  btnContainer2: {
    height: 44 * scale,
    width: ScreenWidth - 32 * scale,
    marginTop: 24 * scale,
    marginHorizontal: 16 * scale,
    borderRadius: 5 * scale,
    borderColor: Color.text_desc,
    alignItems: "center",
    justifyContent: "center",
    backgroundColor: "#FAFAFA",
  },
});
